package EBM.UI;

import java.io.IOException;
import java.text.Format;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.MessageBox;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.TableItem;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

import EBM.BLL.SocketConnection;
import EBM.BLL.Util;

public class SystemAdmin extends org.eclipse.swt.widgets.Composite {
	public static Tree tree1;
	private Combo cboProjectQ;
	private Table tblUserQuery;
	private Label lblUserTypeQ;
	private Label lblProjectQ;
	private Label lblUserNameQ;
	private Label lblUserIdQ;
	private Label lblUserType;
	private Label lblUserNameR;
	private Label lblUserIdR;
	private Button btnDeleteQ;
	private Button btnSaveQ;
	private Button btnReviewQ;
	private Button btnCommonUserQ;
	private Button btnAdminQ;
	private Button btnResetUser;
	private Button btnAddUser;
	private Button btnReview;
	private Button btnCommonUser;
	private Button btnAdmin;
	private Button btnAllTypeQ;
	private Text txtUserNameQ;
	private Text txtUserIdQ;
	private Text txtUserNameR;
	private Text txtUserIdR;
	private Text txtProNameM;
	private Text txtProVersionM;
	private Text txtSubsysM;
	private Composite cptUserQuery;
	private Composite cptRegister;
	private TreeItem treeItem13;
	private TreeItem treeItem12;
	private TreeItem treeItem11;
	private TreeItem treeItem10;
	private TreeItem treeItem9;
	private TreeItem treeItem8;
	private TreeItem treeItem7;
	private TreeItem treeItem6;
	private TreeItem treeItem5;
	private TreeItem treeItem4;
	private TreeItem treeItem3;
	private TreeItem treeItem2;
	private TreeItem treeItem1;
	private Label lblNewPwd2;
	private Composite cptBug;
	private Button btnResetMember;
	private Button btnAddPro;
	private Button btnToRight;
	private Button btnToLeft;
	private List listRightM;
	private List listLeftM;
	private List listRight;
	private List listLeft;
	private Label lblProIdM;
	private Label lblProNameM;
	private Label lblProVersionM;
	private Label lblSubsysM;
	private Label lblSubsysExsitedM;
	private Combo cboSubsysExisted;
	private Combo cboSubsysExistedM;
	private Label lblSubsysExisted;
	private Button btnAddSubsys;
	private Text txtSubsys;
	private Label lblSubsys;
	private Composite cptProM;
	private Text txtProVersion;
	private Text txtProName;
	private Text txtProId;
	private Label lblProVersion;
	private Label lblProName;
	private Label lblProId;
	private Composite cptProject;
	private Button btnQueryQ;
	private Button btnResetPwdM;
	private Button btnSubmitPwdM;
	private Button btnAddSubsysM;
	private Button btnToLeftM;
	private Button btnToRightM;
	private Button btnModifyM;
	private Text txtNewPwd2;
	private Text txtNewPwd;
	private Text txtOldPwd;
	private Label lblNewPwd;
	private Label lblOldPwd;
	private Composite cptPwdModify;
	private TableColumn tableColumn1;
	private TableColumn tableColumn2;
	private TableColumn tableColumn3;
	private TableColumn tableColumn4;
	private TableColumn tableColumn5;
	private TableColumn tableColumn6;
	private TableColumn tableColumn7;
	private TableColumn tableColumn8;
	private TableColumn tableColumn9;
	private TableColumn tableColumn10;
	private Text txtTime;
	private Combo cboProIdB;
	private Combo cboProVersionB;
	private Text txtBugSummary;
	private Text txtAttach;
	private Text txtRecurStep;
	private TreeItem treeItem14;
	private Combo combo7;
	private Table table2;
	private Label label45;
	private Composite composite7;
	private Combo cboProIdM;
	private Button btnSubmitBug;
	private Button btnSaveBug;
	private Combo cboClose;
	private Combo cboReview;
	private Button btnClose;
	private Button btnAssignReview;
	private Label lblNext;
	private Label lblAttach;
	private Text txtBugDetail;
	private Label lblRecurStep;
	private Label lblBugDetail;
	private Combo cboRecur;
	private Label lblBugSummary;
	private Combo cboSeverity;
	private Label lblSeverity;
	private Text txtSoft;
	private Label lblSoft;
	private Text txtHard;
	private Label lblHard;
	private Combo cboSubsysB;
	private Label lblSubsysB;
	private Label lblProVersionB;
	private Label lblProIdB;
	private Label lblTime;
	private Text txtSubmit;
	private Label lblSubmit;
	private Text txtBugId;
	private Label lblBugId;
	private Button btnDeleteMember;
	private Button btnDeleteSubsysM;

	private ArrayList<String> addProjectUserId = new ArrayList<String>();
	private ArrayList<String> addProjectUserName = new ArrayList<String>();

	private ArrayList<String> editProjectId = new ArrayList<String>();
	private ArrayList<String> editProjectName = new ArrayList<String>();

	private ArrayList<String> editUserProjectId = new ArrayList<String>();
	private ArrayList<String> editUserProjectName = new ArrayList<String>();

	private ArrayList<String> editProjectUserId = new ArrayList<String>();
	private ArrayList<String> editProjectUserName = new ArrayList<String>();

	private ArrayList<String> addBugReportProjectId = new ArrayList<String>();
	private ArrayList<String> addBugReportProjectName = new ArrayList<String>();

	private ArrayList<String> addBugReportUserId = new ArrayList<String>();
	private ArrayList<String> addBugReportUserName = new ArrayList<String>();

	private ArrayList<String> getProjectByUserIdProjectId = new ArrayList<String>();
	private ArrayList<String> getProjectByUserIdProjectName = new ArrayList<String>();

	public static String userName;
	public static Display display;
	public static Shell shell;
	private MessageBox box = new MessageBox(shell, SWT.YES | SWT.ICON_WARNING);
	private MessageBox box1 = new MessageBox(shell, SWT.YES | SWT.NO
			| SWT.ICON_WARNING);
	private MessageBox success = new MessageBox(shell, SWT.YES
			| SWT.ICON_INFORMATION);
	private MessageBox failed = new MessageBox(shell, SWT.YES | SWT.ICON_ERROR);

	// 新增
	private Group composite1Group;
	private Group composite2Group;
	private Group composite4Group1;
	private Group composite4Group2;
	private Group composite4Group3;
	private Button btnResetPro;
	private Group composite5Group1;
	private Group composite5Group2;
	private Group composite5Group3;
	private Group composite6Group1;
	private Group composite6Group2;
	private Group composite6Group3;
	private Group composite6Group4;
	private Group composite3Group;

	/**
	 * Auto-generated main method to display this
	 * org.eclipse.swt.widgets.Composite inside a new Shell.
	 */
	/*
	 * public static void main(String[] args) { showGUI(); }
	 */

	/**
	 * Auto-generated method to display this org.eclipse.swt.widgets.Composite
	 * inside a new Shell.
	 */
	public static void showGUI() {
		display = Display.getDefault();
		shell = new Shell(display, SWT.CLOSE | SWT.MIN);
		SystemAdmin inst = new SystemAdmin(shell, SWT.NULL);
		Point size = inst.getSize();
		shell.setLayout(new FillLayout());
		shell.layout();
		shell.setText("系统管理员主界面");
		if (size.x == 0 && size.y == 0) {
			inst.pack();
			shell.pack();
		} else {
			Rectangle shellBounds = shell.computeTrim(0, 0, size.x, size.y);
			shell.setSize(shellBounds.width, shellBounds.height);
		}
		shell
				.setLocation(display.getClientArea().width / 2
						- shell.getSize().x / 2, display.getClientArea().height
						/ 2 - shell.getSize().y / 2);
		shell.open();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
	}

	public SystemAdmin(org.eclipse.swt.widgets.Composite parent, int style) {
		super(parent, style);
		initGUI();
		TreeVisible(7);
		InitProjectByUserId();
		InitBugByProject();
	}

	private void initGUI() {
		try {
			this.setLayout(new FormLayout());
			this.setSize(726, 475);
			{
				cptBug = new Composite(this, SWT.NONE);
				FormData fd_cptBug = new FormData();
				fd_cptBug.width = 534;
				fd_cptBug.height = 476;
				fd_cptBug.left = new FormAttachment(265, 1000, 0);
				fd_cptBug.right = new FormAttachment(1000, 1000, 0);
				fd_cptBug.top = new FormAttachment(1, 1000, 0);
				fd_cptBug.bottom = new FormAttachment(1003, 1000, 0);
				cptBug.setLayoutData(fd_cptBug);
				cptBug.setLayout(null);

				composite6Group1 = new Group(cptBug, SWT.NONE);
				composite6Group2 = new Group(cptBug, SWT.NONE);
				composite6Group3 = new Group(cptBug, SWT.NONE);
				composite6Group4 = new Group(cptBug, SWT.NONE);

				/*
				 * composite6Group1.setText("缺陷基本信息");
				 * composite6Group2.setText("缺陷描述");
				 * composite6Group3.setText("缺陷重现信息");
				 * composite6Group4.setText("下一步处理");
				 */

				composite6Group1.setBounds(15, 30, 470, 113);
				composite6Group2.setBounds(15, 140, 470, 113);
				composite6Group3.setBounds(15, 250, 470, 113);
				composite6Group4.setBounds(15, 394, 406, 80);

				/*
				 * { label27 = new Label(composite6, SWT.NONE);
				 * label27.setText("缺陷报告单"); label27.setBounds(231, 12, 77, 17); }
				 */
				{
					lblBugId = new Label(cptBug, SWT.NONE);
					lblBugId.setText("缺陷报告单ID");
					lblBugId.setBounds(10, 10, 76, 19);
				}
				{
					txtBugId = new Text(cptBug, SWT.NONE);
					txtBugId.setText("D****");
					txtBugId.setBounds(110, 10, 60, 19);
					txtBugId.setEditable(false);
				}
				{
					lblSubmit = new Label(cptBug, SWT.NONE);
					lblSubmit.setText("提交人");
					lblSubmit.setBounds(200, 10, 58, 14);
				}
				{
					txtSubmit = new Text(cptBug, SWT.NONE);
					txtSubmit.setBounds(264, 10, 60, 18);
					txtSubmit.setEditable(false);
				}
				{
					lblTime = new Label(cptBug, SWT.NONE);
					lblTime.setText("提交时间");
					lblTime.setBounds(350, 10, 60, 19);
				}
				{
					txtTime = new Text(cptBug, SWT.NONE);
					txtTime.setBounds(421, 10, 59, 19);
					txtTime.setEditable(false);
				}
				{
					lblProIdB = new Label(composite6Group1, SWT.NONE);
					lblProIdB.setText("项目编号");
					lblProIdB.setBounds(25, 25, 50, 16);
				}
				{
					cboProIdB = new Combo(composite6Group1, SWT.READ_ONLY);
					cboProIdB.setBounds(80, 20, 96, 16);
					cboProIdB.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							cboProIdBWidgetSelected(evt);
						}
					});
				}
				{
					lblProVersionB = new Label(composite6Group1, SWT.NONE);
					lblProVersionB.setText("版本");
					lblProVersionB.setBounds(190, 25, 30, 16);
				}
				{
					cboProVersionB = new Combo(composite6Group1, SWT.READ_ONLY);
					cboProVersionB.setBounds(225, 20, 66, 18);
				}
				{
					lblSubsysB = new Label(composite6Group1, SWT.NONE);
					lblSubsysB.setText("子项目");
					lblSubsysB.setBounds(305, 25, 38, 16);
				}
				{
					cboSubsysB = new Combo(composite6Group1, SWT.READ_ONLY);
					cboSubsysB.setBounds(350, 20, 107, 18);
				}
				{
					lblHard = new Label(composite6Group1, SWT.NONE);
					lblHard.setText("硬件环境");
					lblHard.setBounds(25, 55, 55, 18);
				}
				{
					txtHard = new Text(composite6Group1, SWT.BORDER);
					txtHard.setBounds(80, 50, 147, 23);
				}
				{
					lblSoft = new Label(composite6Group1, SWT.NONE);
					lblSoft.setText("软件环境");
					lblSoft.setBounds(260, 55, 50, 20);
				}
				{
					txtSoft = new Text(composite6Group1, SWT.BORDER);
					txtSoft.setBounds(318, 50, 143, 23);
				}
				{
					lblSeverity = new Label(composite6Group1, SWT.NONE);
					lblSeverity.setText("严重程度");
					lblSeverity.setBounds(25, 85, 55, 17);
				}
				{
					cboSeverity = new Combo(composite6Group1, SWT.READ_ONLY);
					String[] items = { "致命", "严重", "一般", "提示" };
					cboSeverity.setItems(items);
					cboSeverity.select(3);
					cboSeverity.setBounds(80, 80, 80, 20);
				}
				{
					lblBugSummary = new Label(composite6Group2, SWT.NONE);
					lblBugSummary.setText("缺陷概要描述");
					lblBugSummary.setBounds(25, 15, 77, 23);
				}
				{
					txtBugSummary = new Text(composite6Group2, SWT.BORDER);
					txtBugSummary.setBounds(110, 10, 349, 19);
				}
				{
					lblRecurStep = new Label(composite6Group3, SWT.NONE);
					lblRecurStep.setText("是否重现");
					lblRecurStep.setBounds(25, 20, 59, 16);
				}
				{
					cboRecur = new Combo(composite6Group3, SWT.READ_ONLY);
					String[] items = { "是", "否" };
					cboRecur.setItems(items);
					cboRecur.select(0);
					cboRecur.setBounds(110, 15, 58, 17);
					cboRecur.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							if (cboRecur.getSelectionIndex() == 0)
								txtRecurStep.setEditable(true);
							else if (cboRecur.getSelectionIndex() == 1) {
								txtRecurStep.setText("");
								txtRecurStep.setEditable(false);
							}

						}
					});
				}
				{
					lblBugDetail = new Label(composite6Group2, SWT.NONE);
					lblBugDetail.setText("缺陷详细描述");
					lblBugDetail.setBounds(25, 35, 74, 18);
				}
				{
					lblRecurStep = new Label(composite6Group3, SWT.NONE);
					lblRecurStep.setText("重现步骤");
					lblRecurStep.setBounds(25, 45, 58, 18);
				}
				{
					txtBugDetail = new Text(composite6Group2, SWT.WRAP
							| SWT.V_SCROLL | SWT.MULTI | SWT.BORDER);
					txtBugDetail.setBounds(110, 35, 349, 74);
				}
				{
					lblAttach = new Label(cptBug, SWT.NONE);
					lblAttach.setText("附件");
					lblAttach.setBounds(40, 370, 50, 19);
				}
				{
					lblNext = new Label(composite6Group4, SWT.NONE);
					lblNext.setText("指定下一步处理");
					lblNext.setBounds(30, 15, 90, 21);
				}
				{
					btnAssignReview = new Button(composite6Group4, SWT.RADIO
							| SWT.LEFT);
					btnAssignReview.setText("指定审核人");
					btnAssignReview.setBounds(125, 15, 90, 18);
					btnAssignReview
							.addSelectionListener(new SelectionAdapter() {
								public void widgetSelected(SelectionEvent evt) {
									cboReview.setEnabled(true);
									cboClose.setEnabled(false);
								}
							});
				}
				{
					btnClose = new Button(composite6Group4, SWT.RADIO
							| SWT.LEFT);
					btnClose.setText("关闭");
					btnClose.setBounds(125, 35, 50, 21);
					btnClose.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							cboReview.setEnabled(false);
							cboClose.setEnabled(true);
						}
					});
				}
				{
					cboReview = new Combo(composite6Group4, SWT.READ_ONLY);
					cboReview.setBounds(240, 15, 96, 20);
				}
				{
					cboClose = new Combo(composite6Group4, SWT.READ_ONLY);
					String[] items = { "正常", "重复", "拒绝", "无效" };
					cboClose.setItems(items);
					cboClose.select(0);
					cboClose.setBounds(200, 45, 136, 20);
				}
				{
					btnSaveBug = new Button(cptBug, SWT.PUSH | SWT.CENTER);
					btnSaveBug.setText("保存");
					btnSaveBug.setBounds(430, 410, 61, 23);
					btnSaveBug.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnSaveBugWidgetSelected(evt);
						}
					});
				}
				{
					btnSubmitBug = new Button(cptBug, SWT.PUSH | SWT.CENTER);
					btnSubmitBug.setText("提交");
					btnSubmitBug.setBounds(430, 445, 59, 23);
					btnSubmitBug.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnSubmitBugWidgetSelected(evt);
						}
					});
				}
				{
					txtRecurStep = new Text(composite6Group3, SWT.WRAP
							| SWT.V_SCROLL | SWT.MULTI | SWT.BORDER);
					txtRecurStep.setBounds(110, 40, 349, 69);
				}
				{
					txtAttach = new Text(cptBug, SWT.MULTI | SWT.WRAP
							| SWT.BORDER);
					txtAttach.setBounds(126, 370, 348, 22);
				}
			}
			{
				composite7 = new Composite(this, SWT.NONE);
				FormData composite7LData = new FormData();
				composite7LData.width = 533;
				composite7LData.height = 475;
				composite7LData.left = new FormAttachment(0, 1000, 193);
				composite7LData.top = new FormAttachment(0, 1000, 0);
				composite7.setLayoutData(composite7LData);
				composite7.setLayout(null);
				{
					label45 = new Label(composite7, SWT.NONE);
					label45.setText("项目");
					label45.setBounds(17, 12, 36, 18);
				}
				{
					table2 = new Table(composite7, SWT.NONE);
					table2.setBounds(0, 50, 533, 425);
					tableColumn5 = new TableColumn(table2, SWT.CENTER);
					tableColumn6 = new TableColumn(table2, SWT.CENTER);
					tableColumn7 = new TableColumn(table2, SWT.CENTER);
					tableColumn8 = new TableColumn(table2, SWT.CENTER);
					tableColumn9 = new TableColumn(table2, SWT.CENTER);
					tableColumn10 = new TableColumn(table2, SWT.CENTER);
					tableColumn5.setText("");
					tableColumn6.setText("问题单号");
					tableColumn7.setText("当前责任人");
					tableColumn8.setText("当前状态");
					tableColumn9.setText("问题概要描述");
					tableColumn10.setText("停留天数");
					tableColumn5.setWidth(25);
					tableColumn6.setWidth(80);
					tableColumn7.setWidth(80);
					tableColumn8.setWidth(80);
					tableColumn9.setWidth(169);
					tableColumn10.setWidth(70);
					table2.setHeaderVisible(true);
					// add ????
					// table2.setLinesVisible(true);
					table2.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							table2WidgetSelected(evt);
						}
					});
				}
				{
					combo7 = new Combo(composite7, SWT.READ_ONLY);
					combo7.setBounds(53, 10, 209, 20);
					combo7.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							combo7WidgetSelected(evt);
						}
					});
				}
			}
			{
				cptProM = new Composite(this, SWT.NONE);
				FormData fd_cptProM = new FormData();
				fd_cptProM.width = 534;
				fd_cptProM.height = 474;
				fd_cptProM.left = new FormAttachment(0, 1000, 192);
				fd_cptProM.top = new FormAttachment(0, 1000, 1);
				cptProM.setLayoutData(fd_cptProM);
				cptProM.setLayout(null);

				composite5Group1 = new Group(cptProM, SWT.NONE);
				composite5Group2 = new Group(cptProM, SWT.NONE);
				composite5Group3 = new Group(cptProM, SWT.NONE);

				composite5Group1.setText("项目基本信息");
				composite5Group2.setText("项目子系统信息");
				composite5Group3.setText("项目成员信息");

				composite5Group1.setBounds(20, 5, 449, 119);
				composite5Group2.setBounds(20, 130, 449, 86);
				composite5Group3.setBounds(20, 220, 449, 247);

				/*
				 * { label20 = new Label(composite5, SWT.NONE);
				 * label20.setText("项目信息修改"); label20.setBounds(229, 12, 83,
				 * 20); }
				 */
				{
					lblProIdM = new Label(composite5Group1, SWT.NONE);
					lblProIdM.setText("项目ID");
					lblProIdM.setBounds(65, 20, 60, 22);
				}
				{
					lblProNameM = new Label(composite5Group1, SWT.NONE);
					lblProNameM.setText("项目名称");
					lblProNameM.setBounds(65, 60, 59, 22);
				}
				{
					lblProVersionM = new Label(composite5Group1, SWT.NONE);
					lblProVersionM.setText("版本");
					lblProVersionM.setBounds(65, 95, 56, 18);
				}
				{
					cboProIdM = new Combo(composite5Group1, SWT.READ_ONLY);
					cboProIdM.setBounds(130, 20, 243, 22);
					cboProIdM.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							cboProIdMWidgetSelected(evt);
						}
					});
				}
				{
					txtProNameM = new Text(composite5Group1, SWT.BORDER);
					txtProNameM.setBounds(130, 57, 243, 24);
					txtProNameM.setEditable(true);
				}
				{
					txtProVersionM = new Text(composite5Group1, SWT.BORDER);
					txtProVersionM.setBounds(130, 90, 129, 24);
				}
				{
					lblSubsysM = new Label(composite5Group2, SWT.NONE);
					lblSubsysM.setText("子系统");
					lblSubsysM.setBounds(65, 20, 58, 22);
				}
				{
					txtSubsysM = new Text(composite5Group2, SWT.BORDER);
					txtSubsysM.setBounds(130, 20, 240, 24);
				}
				{
					btnAddSubsysM = new Button(composite5Group2, SWT.PUSH
							| SWT.CENTER);
					btnAddSubsysM.setText("添加");
					btnAddSubsysM.setBounds(386, 15, 50, 26);
					btnAddSubsysM.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnAddSubsysMWidgetSelected(evt);
						}
					});
				}
				{
					lblSubsysExsitedM = new Label(composite5Group2, SWT.NONE);
					lblSubsysExsitedM.setText("已有子系统");
					lblSubsysExsitedM.setBounds(65, 55, 60, 20);
				}
				{
					cboSubsysExistedM = new Combo(composite5Group2,
							SWT.READ_ONLY);
					cboSubsysExistedM.setBounds(130, 50, 240, 22);
				}
				/*
				 * { label26 = new Label(composite5Group3, SWT.NONE);
				 * label26.setText("项目人员"); label26.setBounds(62, 20, 63, 25); }
				 */
				{
					listLeftM = new List(composite5Group3, SWT.V_SCROLL
							| SWT.H_SCROLL | SWT.BORDER);
					listLeftM.setBounds(70, 30, 140, 180);
				}
				{
					listRightM = new List(composite5Group3, SWT.V_SCROLL
							| SWT.H_SCROLL | SWT.BORDER);
					listRightM.setBounds(300, 30, 140, 180);
				}
				{
					btnToLeftM = new Button(composite5Group3, SWT.PUSH
							| SWT.CENTER);
					btnToLeftM.setText("<<");
					btnToLeftM.setBounds(245, 55, 24, 32);
					btnToLeftM.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnToLeftMWidgetSelected(evt);
						}
					});
				}
				{
					btnToRightM = new Button(composite5Group3, SWT.PUSH
							| SWT.CENTER);
					btnToRightM.setText(">>");
					btnToRightM.setBounds(245, 130, 24, 32);
					btnToRightM.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnToRightMWidgetSelected(evt);
						}
					});
				}
				{
					btnModifyM = new Button(composite5Group3, SWT.PUSH
							| SWT.CENTER);
					btnModifyM.setText("修改");
					btnModifyM.setBounds(225, 215, 60, 27);
					btnModifyM.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnModifyMWidgetSelected(evt);
						}
					});
				}
				{
					btnDeleteSubsysM = new Button(composite5Group2, SWT.PUSH
							| SWT.CENTER);
					btnDeleteSubsysM.setText("删除");
					btnDeleteSubsysM.setBounds(386, 50, 50, 26);
					btnDeleteSubsysM
							.addSelectionListener(new SelectionAdapter() {
								public void widgetSelected(SelectionEvent evt) {
									btnDeleteSubsysMWidgetSelected(evt);
								}
							});
				}
			}
			{
				cptProject = new Composite(this, SWT.NONE);
				FormData fd_cptProject = new FormData();
				fd_cptProject.width = 534;
				fd_cptProject.height = 474;
				fd_cptProject.left = new FormAttachment(0, 1000, 192);
				fd_cptProject.top = new FormAttachment(0, 1000, 1);
				cptProject.setLayoutData(fd_cptProject);
				cptProject.setLayout(null);

				composite4Group1 = new Group(cptProject, SWT.NONE);
				composite4Group2 = new Group(cptProject, SWT.NONE);
				composite4Group3 = new Group(cptProject, SWT.NONE);

				composite4Group1.setText("项目基本信息");
				composite4Group2.setText("项目子系统信息");
				composite4Group3.setText("项目成员信息");

				composite4Group1.setBounds(20, 5, 449, 119);
				composite4Group2.setBounds(20, 130, 449, 86);
				composite4Group3.setBounds(20, 220, 449, 254);

				/*
				 * { label13 = new Label(composite4, SWT.NONE);
				 * label13.setText("项目登记"); label13.setBounds(229, 12, 83, 20); }
				 */
				{
					lblProId = new Label(composite4Group1, SWT.NONE);
					lblProId.setText("项目ID");
					lblProId.setBounds(66, 25, 60, 22);
				}
				{
					lblProName = new Label(composite4Group1, SWT.NONE);
					lblProName.setText("项目名称");
					lblProName.setBounds(66, 53, 59, 16);
				}
				{
					lblProVersion = new Label(composite4Group1, SWT.NONE);
					lblProVersion.setText("版本");
					lblProVersion.setBounds(66, 84, 56, 18);
				}
				{
					txtProId = new Text(composite4Group1, SWT.BORDER);
					txtProId.setBounds(132, 22, 243, 21);
				}
				{
					txtProName = new Text(composite4Group1, SWT.BORDER);
					txtProName.setBounds(131, 50, 242, 21);
				}
				{
					txtProVersion = new Text(composite4Group1, SWT.BORDER);
					txtProVersion.setBounds(132, 81, 129, 24);
				}
				{
					lblSubsys = new Label(composite4Group2, SWT.NONE);
					lblSubsys.setText("子系统");
					lblSubsys.setBounds(66, 26, 58, 23);
				}
				{
					txtSubsys = new Text(composite4Group2, SWT.BORDER);
					txtSubsys.setBounds(134, 23, 240, 23);
				}

				// 重置项目的button未实现！！！
				{
					btnResetPro = new Button(composite4Group1, SWT.PUSH
							| SWT.CENTER);
					btnResetPro.setText("重置");
					btnResetPro.setBounds(376, 79, 50, 26);
					btnResetPro.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							// button18WidgetSelected(evt);
							txtProId.setText("");
							txtProName.setText("");
							txtProVersion.setText("");
							
						}
					});
				}

				{
					btnAddSubsys = new Button(composite4Group2, SWT.PUSH
							| SWT.CENTER);
					btnAddSubsys.setText("添加");
					btnAddSubsys.setBounds(380, 50, 50, 26);
					btnAddSubsys.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnAddSubsysWidgetSelected(evt);
						}
					});
				}
				{
					lblSubsysExisted = new Label(composite4Group2, SWT.NONE);
					lblSubsysExisted.setText("已有子系统");
					lblSubsysExisted.setBounds(66, 55, 62, 23);
				}
				{
					cboSubsysExisted = new Combo(composite4Group2,
							SWT.READ_ONLY);
					cboSubsysExisted.setBounds(134, 52, 240, 20);
				}
				{
					btnToLeft = new Button(composite4Group3, SWT.PUSH
							| SWT.CENTER);
					btnToLeft.setText("<<");
					btnToLeft.setBounds(245, 55, 24, 32);
					btnToLeft.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnToLeftWidgetSelected(evt);
						}
					});
				}
				{
					btnToRight = new Button(composite4Group3, SWT.PUSH
							| SWT.CENTER);
					btnToRight.setText(">>");
					btnToRight.setBounds(245, 130, 24, 32);
					btnToRight.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnToRightWidgetSelected(evt);
						}
					});
				}
				{
					btnAddPro = new Button(composite4Group1, SWT.PUSH
							| SWT.CENTER);
					btnAddPro.setText("添加");
					btnAddPro.setBounds(305, 79, 50, 26);
					btnAddPro.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnAddProWidgetSelected(evt);
						}
					});
				}
				{
					btnResetMember = new Button(composite4Group3, SWT.PUSH
							| SWT.CENTER);
					btnResetMember.setText("重置");
					btnResetMember.setBounds(315, 210, 60, 27);
					btnResetMember.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnResetMemberWidgetSelected(evt);
						}
					});
				}
				{
					btnDeleteMember = new Button(composite4Group3, SWT.PUSH
							| SWT.CENTER);
					btnDeleteMember.setText("删除");
					btnDeleteMember.setBounds(140, 210, 60, 27);
					btnDeleteMember
							.addSelectionListener(new SelectionAdapter() {
								public void widgetSelected(SelectionEvent evt) {
									btnDeleteMemberWidgetSelected(evt);
								}
							});
				}
				{
					listLeft = new List(composite4Group3, SWT.V_SCROLL
							| SWT.H_SCROLL | SWT.BORDER);
					listLeft.setBounds(70, 20, 140, 180);
				}
				{
					listRight = new List(composite4Group3, SWT.V_SCROLL
							| SWT.H_SCROLL | SWT.BORDER);
					listRight.setBounds(300, 20, 140, 180);
				}
			}

			// 用户信息——用户登记
			{
				FormData fd_cptRegister = new FormData();
				fd_cptRegister.width = 534;
				fd_cptRegister.height = 475;
				fd_cptRegister.top = new FormAttachment(1, 1000, 0);
				fd_cptRegister.right = new FormAttachment(1000, 1000, 0);
				fd_cptRegister.bottom = new FormAttachment(1001, 1000, 0);
				fd_cptRegister.left = new FormAttachment(265, 1000, 0);
				cptRegister = new Composite(this, SWT.NONE);
				// composite1.setBounds(265, 0, 534, 475);
				cptRegister.setLayout(null);
				cptRegister.setLayoutData(fd_cptRegister);

				// 为增加边框的效果，将所有的组件都放在一个Group中
				composite1Group = new Group(cptRegister, SWT.NONE);
				composite1Group.setText("用户登记");

				composite1Group.setBounds(35, 26, 432, 377);

				{
					lblUserIdR = new Label(composite1Group, SWT.NONE);
					lblUserIdR.setText("用户ID");
					lblUserIdR.setBounds(86, 68, 51, 24);
				}
				{
					txtUserIdR = new Text(composite1Group, SWT.BORDER);
					txtUserIdR.setBounds(169, 65, 163, 27);
				}
				{
					lblUserNameR = new Label(composite1Group, SWT.NONE);
					lblUserNameR.setText("用户姓名");
					lblUserNameR.setBounds(86, 123, 60, 30);
				}
				{
					txtUserNameR = new Text(composite1Group, SWT.BORDER);
					txtUserNameR.setBounds(169, 120, 166, 26);
				}
				{
					lblUserType = new Label(composite1Group, SWT.NONE);
					lblUserType.setText("用户类别");
					lblUserType.setBounds(86, 186, 60, 17);
				}
				{
					btnAdmin = new Button(composite1Group, SWT.RADIO | SWT.LEFT);
					btnAdmin.setText("系统管理员");
					btnAdmin.setBounds(170, 179, 127, 30);
				}
				{
					btnCommonUser = new Button(composite1Group, SWT.RADIO
							| SWT.LEFT);
					btnCommonUser.setText("普通用户");
					btnCommonUser.setSelection(true);
					btnCommonUser.setBounds(170, 221, 118, 30);
				}
				{
					btnReview = new Button(composite1Group, SWT.RADIO
							| SWT.LEFT);
					btnReview.setText("审查用户");
					btnReview.setBounds(170, 263, 127, 30);
				}
				{
					btnAddUser = new Button(composite1Group, SWT.PUSH
							| SWT.CENTER);
					btnAddUser.setText("添加");
					btnAddUser.setBounds(139, 334, 85, 30);
					btnAddUser.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnAddUserWidgetSelected(evt);
						}
					});
				}
				{
					btnResetUser = new Button(composite1Group, SWT.PUSH
							| SWT.CENTER);
					btnResetUser.setText("重置");
					btnResetUser.setBounds(309, 334, 85, 30);
					btnResetUser.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnAdmin.setSelection(false);
							btnCommonUser.setSelection(true);
							btnReview.setSelection(false);
							txtUserIdR.setText("");
							txtUserNameR.setText("");
						}
					});
				}
				/*
				 * { label12 = new Label(composite1, SWT.NONE);
				 * label12.setText("用户登记"); label12.setBounds(207, 44, 86, 30); }
				 */
			}
			{
				cptPwdModify = new Composite(this, SWT.NONE);
				FormData fd_cptPwdModify = new FormData();
				fd_cptPwdModify.width = 532;
				fd_cptPwdModify.height = 475;
				fd_cptPwdModify.left = new FormAttachment(0, 1000, 194);
				fd_cptPwdModify.top = new FormAttachment(0, 1000, 0);
				cptPwdModify.setLayoutData(fd_cptPwdModify);
				cptPwdModify.setLayout(null);

				composite3Group = new Group(cptPwdModify, SWT.NONE);
				composite3Group.setText("密码修改");
				composite3Group.setBounds(25, 30, 422, 358);

				/*
				 * { label8 = new Label(composite3Group, SWT.NONE);
				 * label8.setText("修改密码"); label8.setBounds(220, 62, 69, 29); }
				 */
				{
					lblOldPwd = new Label(composite3Group, SWT.NONE);
					lblOldPwd.setText("请输入原密码：");
					lblOldPwd.setBounds(62, 61, 136, 23);
				}
				{
					lblNewPwd = new Label(composite3Group, SWT.NONE);
					lblNewPwd.setText("请输入新密码：");
					lblNewPwd.setBounds(62, 134, 130, 24);
				}
				{
					txtOldPwd = new Text(composite3Group, SWT.PASSWORD
							| SWT.BORDER);
					txtOldPwd.setBounds(204, 58, 182, 24);
				}
				{
					txtNewPwd = new Text(composite3Group, SWT.PASSWORD
							| SWT.BORDER);
					txtNewPwd.setBounds(204, 131, 182, 24);
				}
				{
					lblNewPwd2 = new Label(composite3Group, SWT.NONE);
					lblNewPwd2.setText("请再次输入新密码：");
					lblNewPwd2.setBounds(62, 205, 122, 25);
				}
				{
					txtNewPwd2 = new Text(composite3Group, SWT.PASSWORD
							| SWT.BORDER);
					txtNewPwd2.setBounds(204, 202, 182, 25);
				}
				{
					btnSubmitPwdM = new Button(composite3Group, SWT.PUSH
							| SWT.CENTER);
					btnSubmitPwdM.setText("确定");
					btnSubmitPwdM.setBounds(140, 280, 85, 30);
					btnSubmitPwdM.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnSubmitPwdMWidgetSelected(evt);
						}
					});
				}
				{
					btnResetPwdM = new Button(composite3Group, SWT.PUSH
							| SWT.CENTER);
					btnResetPwdM.setText("重置");
					btnResetPwdM.setBounds(295, 280, 85, 30);
					btnResetPwdM.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							txtOldPwd.setText("");
							txtNewPwd.setText("");
							txtNewPwd2.setText("");
						}
					});
				}
			}
			// 用户信息维护
			{
				FormData fd_cptUserQuery = new FormData();
				fd_cptUserQuery.right = new FormAttachment(100, -5);
				fd_cptUserQuery.width = 534;
				fd_cptUserQuery.height = 475;
				fd_cptUserQuery.top = new FormAttachment(1, 1000, 0);
				fd_cptUserQuery.bottom = new FormAttachment(1001, 1000, 0);
				fd_cptUserQuery.left = new FormAttachment(265, 1000, 0);
				cptUserQuery = new Composite(this, SWT.NONE);
				cptUserQuery.setLayout(null);
				cptUserQuery.setLayoutData(fd_cptUserQuery);

				composite2Group = new Group(cptUserQuery, SWT.NONE);
				composite2Group.setText("用户信息查询");

				composite2Group.setBounds(22, 10, 477, 125);

				{
					lblUserIdQ = new Label(composite2Group, SWT.NONE);
					lblUserIdQ.setText("用户ID");
					lblUserIdQ.setBounds(32, 33, 50, 19);
				}
				{
					txtUserIdQ = new Text(composite2Group, SWT.BORDER);
					txtUserIdQ.setBounds(88, 30, 64, 24);
				}
				{
					lblUserNameQ = new Label(composite2Group, SWT.NONE);
					lblUserNameQ.setText("用户姓名");
					lblUserNameQ.setBounds(171, 33, 58, 19);
				}
				{
					txtUserNameQ = new Text(composite2Group, SWT.BORDER);
					txtUserNameQ.setBounds(235, 30, 81, 24);
				}
				{
					lblProjectQ = new Label(composite2Group, SWT.NONE);
					lblProjectQ.setText("所属项目");
					lblProjectQ.setBounds(322, 33, 46, 24);
				}
				{
					cboProjectQ = new Combo(composite2Group, SWT.READ_ONLY);
					cboProjectQ.setBounds(378, 30, 89, 25);
				}
				{
					lblUserTypeQ = new Label(composite2Group, SWT.NONE);
					lblUserTypeQ.setText("用户类别");
					lblUserTypeQ.setBounds(32, 80, 55, 22);
				}
				{
					btnAdminQ = new Button(composite2Group, SWT.RADIO
							| SWT.LEFT);
					btnAdminQ.setText("系统管理员");
					btnAdminQ.setBounds(90, 77, 75, 22);
				}
				{
					btnCommonUserQ = new Button(composite2Group, SWT.RADIO
							| SWT.LEFT);
					btnCommonUserQ.setText("普通用户");
					btnCommonUserQ.setBounds(171, 77, 64, 22);
				}
				{
					btnReviewQ = new Button(composite2Group, SWT.RADIO
							| SWT.LEFT);
					btnReviewQ.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(final SelectionEvent e) {
						}
					});
					btnReviewQ.setText("审查用户");
					btnReviewQ.setBounds(241, 77, 75, 22);
				}
				{
					btnAllTypeQ = new Button(composite2Group, SWT.RADIO
							| SWT.LEFT);
					btnAllTypeQ.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(final SelectionEvent e) {
						}
					});
					btnAllTypeQ.setText("任意类型用户");
					btnAllTypeQ.setBounds(318, 77, 89, 22);
				}
				{
					btnDeleteQ = new Button(cptUserQuery, SWT.PUSH | SWT.CENTER);
					btnDeleteQ.setText("删除");
					btnDeleteQ.setBounds(363, 409, 85, 30);
					btnDeleteQ.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnDeleteQWidgetSelected(evt);
						}
					});
				}
				{
					btnSaveQ = new Button(cptUserQuery, SWT.PUSH | SWT.CENTER);
					btnSaveQ.setText("修改"); // ddd
					btnSaveQ.setBounds(219, 409, 85, 30);
					btnSaveQ.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnSaveQWidgetSelected(evt);
						}
					});
				}
				{
					btnQueryQ = new Button(composite2Group, SWT.PUSH
							| SWT.CENTER);
					btnQueryQ.setText("查询");
					btnQueryQ.setBounds(411, 76, 54, 25);
					btnQueryQ.addSelectionListener(new SelectionAdapter() {
						public void widgetSelected(SelectionEvent evt) {
							btnQueryQWidgetSelected(evt);
						}
					});
				}
				{
					tblUserQuery = new Table(cptUserQuery, SWT.BORDER);
					tblUserQuery.setBounds(22, 155, 477, 240);
					tableColumn1 = new TableColumn(tblUserQuery, SWT.CENTER);
					tableColumn2 = new TableColumn(tblUserQuery, SWT.CENTER);
					tableColumn3 = new TableColumn(tblUserQuery, SWT.CENTER);
					tableColumn3.setText("用户姓名");
					tableColumn3.setWidth(110);
					tableColumn4 = new TableColumn(tblUserQuery, SWT.CENTER);
					tableColumn1.setText("");
					tableColumn2.setText("用户ID");
					tableColumn4.setText("用户类型");
					tableColumn1.setWidth(50);
					tableColumn2.setWidth(110);
					tableColumn4.setWidth(110);
					tblUserQuery.setHeaderVisible(true);
				}
			}
			{
				FormData tree1LData = new FormData();
				tree1LData.width = 175;
				tree1LData.height = 458;
				tree1LData.left = new FormAttachment(0, 1000, 0);
				tree1LData.top = new FormAttachment(1, 1000, 0);
				tree1LData.right = new FormAttachment(265, 1000, 0);
				tree1LData.bottom = new FormAttachment(1001, 1000, 0);
				tree1 = new Tree(this, SWT.NONE);
				tree1.setLayoutData(tree1LData);
				tree1.addListener(SWT.MouseDown, new Listener() {
					public void handleEvent(Event event) {
						Point point = new Point(event.x, event.y);
						TreeItem item = tree1.getItem(point);
						if (item != null)
							tree1WidgetSelected(event, item);
					}
				});
				{
					treeItem1 = new TreeItem(tree1, SWT.NONE);
					treeItem1.setText("功能菜单");
					{
						treeItem2 = new TreeItem(treeItem1, SWT.NONE);
						treeItem2.setText("用户信息管理");
						{
							treeItem6 = new TreeItem(treeItem2, SWT.NONE);
							treeItem6.setText("用户登记");
							{
								treeItem7 = new TreeItem(treeItem2, SWT.NONE);
								treeItem7.setText("用户信息维护");
							}
						}
						{
							treeItem3 = new TreeItem(treeItem1, SWT.NONE);
							treeItem3.setText("项目信息管理");
							{
								treeItem8 = new TreeItem(treeItem3, SWT.NONE);
								treeItem8.setText("项目登记");
							}
							{
								treeItem9 = new TreeItem(treeItem3, SWT.NONE);
								treeItem9.setText("项目信息维护");
							}
						}
						{
							treeItem4 = new TreeItem(treeItem1, SWT.NONE);
							treeItem4.setText("缺陷信息管理");
							{
								treeItem10 = new TreeItem(treeItem4, SWT.NONE);
								treeItem10.setText("缺陷报告");
							}
							{
								treeItem11 = new TreeItem(treeItem4, SWT.NONE);
								treeItem11.setText("缺陷处理");
							}
							{
								treeItem12 = new TreeItem(treeItem4, SWT.NONE);
								treeItem12.setText("缺陷查询");
							}
						}
						{
							treeItem5 = new TreeItem(treeItem1, SWT.NONE);
							treeItem5.setText("个人信息管理");
							{
								treeItem13 = new TreeItem(treeItem5, SWT.NONE);
								treeItem13.setText("修改密码");
							}
						}
						{
							treeItem14 = new TreeItem(treeItem1, SWT.NONE);
							treeItem14.setText("退出系统");
						}
					}
				}
			}
			this.layout();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void tree1WidgetSelected(Event evt, TreeItem item) {
		try {
			if (item.getText().equals("功能菜单")) {
				TreeVisible(7);
				InitProjectByUserId();
				InitBugByProject();
				lblBugId.setVisible(false);
				txtBugId.setVisible(false);
				lblSubmit.setVisible(false);
				txtSubmit.setVisible(false);
				lblTime.setVisible(false);
				txtTime.setVisible(false);
			} else if (item.getText().equals("用户信息管理")) {
				TreeVisible(1);
				btnAdmin.setSelection(false);
				btnCommonUser.setSelection(true);
				btnReview.setSelection(false);
			} else if (item.getText().equals("项目信息管理")) {
				TreeVisible(4);
				txtProId.setEditable(true);
				txtProName.setEditable(true);
				txtProVersion.setEditable(true);
				ClearAllAddProject();
				InitAddProjectUserList();
			} else if (item.getText().equals("缺陷信息管理")) {
				TreeVisible(6);
				InitCreateBug();
				ClearAllAddBugReport();
				cboReview.setEnabled(true);
				cboClose.setEnabled(false);
				btnAssignReview.setSelection(true);
				btnClose.setSelection(false);
			} else if (item.getText().equals("个人信息管理")) {
				TreeVisible(3);
			} else if (item.getText().equals("用户登记")) {
				TreeVisible(1);
				btnAdmin.setSelection(false);
				btnCommonUser.setSelection(true);
				btnReview.setSelection(false);
			} else if (item.getText().equals("用户信息维护")) {
				TreeVisible(2);
				InitUserProList();
				btnAdminQ.setSelection(false);
				btnCommonUserQ.setSelection(false);
				btnReviewQ.setSelection(false);
				btnAllTypeQ.setSelection(true);
			} else if (item.getText().equals("项目登记")) {
				TreeVisible(4);
				txtProId.setEditable(true);
				txtProName.setEditable(true);
				txtProVersion.setEditable(true);
				ClearAllAddProject();
				InitAddProjectUserList();
			} else if (item.getText().equals("项目信息维护")) {
				TreeVisible(5);
				InitProjectProList();
			} else if (item.getText().equals("缺陷报告")) {
				TreeVisible(6);
				InitCreateBug();
				ClearAllAddBugReport();
				cboReview.setEnabled(true);
				cboClose.setEnabled(false);
				btnAssignReview.setSelection(true);
				btnClose.setSelection(false);
				btnSaveBug.setSelection(true);
				btnSubmitBug.setSelection(true);
			} else if (item.getText().equals("缺陷处理")) {
				TreeVisible(7);
				InitProjectByUserId();
				InitBugByProject();
				lblBugId.setVisible(false);
				txtBugId.setVisible(false);
				lblSubmit.setVisible(false);
				txtSubmit.setVisible(false);
				lblTime.setVisible(false);
				txtTime.setVisible(false);
			} else if (item.getText().equals("缺陷查询")) {
				EMQuery.userType = "0";
				EMQuery.userName = SystemAdmin.userName;
				EMQuery.showGUI();
			} else if (item.getText().equals("修改密码")) {
				TreeVisible(3);
			} else {// 退出系统
				box1.setMessage("确定要退出吗？");
				if (box1.open() == SWT.NO)
					return;
				shell.close();
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	private void TreeVisible(int count) {
		boolean check[] = new boolean[8];
		for (int i = 1; i < 8; i++)
			if (count == i)
				check[i] = true;
			else
				check[i] = false;
		this.cptRegister.setVisible(check[1]);
		this.cptRegister.setEnabled(check[1]);
		this.cptUserQuery.setVisible(check[2]);
		this.cptUserQuery.setEnabled(check[2]);
		this.cptPwdModify.setVisible(check[3]);
		this.cptPwdModify.setEnabled(check[3]);
		this.cptProject.setEnabled(check[4]);
		this.cptProject.setVisible(check[4]);
		this.cptProM.setEnabled(check[5]);
		this.cptProM.setVisible(check[5]);
		this.cptBug.setEnabled(check[6]);
		this.cptBug.setVisible(check[6]);
		this.composite7.setEnabled(check[7]);
		this.composite7.setVisible(check[7]);
	}

	private void btnSubmitPwdMWidgetSelected(SelectionEvent evt) {// 修改密码
		if (txtNewPwd.getText().trim().equals("")) {
			box.setMessage("密码不能为空！");
			box.open();
			return;
		}
		if (!txtNewPwd.getText().trim().equals(txtNewPwd2.getText().trim())) {
			box.setMessage("您两次输入的新密码不一致！");
			box.open();
			return;
		}

		if (Util.isValidPassword(txtNewPwd.getText().trim()) == false) {
			box.setMessage("新密码格式有误，只能由数字和字母组成，长度为6-12位！");
			box.open();
			return;
		}
		try {
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(userName);
			out.add(txtOldPwd.getText());
			out.add(this.txtNewPwd.getText());
			SocketConnection.setCmd("modifypwd");
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();
			if (in == null || in.size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接");
				failed.open();
				return;
			}

			String tag = in.get(0).toString();
			if (tag.equals("1")) { // 修改成功
				box.setMessage("密码修改成功!");
				box.open();
				txtOldPwd.setText("");
				txtNewPwd.setText("");
				txtNewPwd2.setText("");
				return;
			} else if (tag.equals("-1")) {
				box.setMessage("您输入的原密码不正确！");
				box.open();
				return;
			} else {
				box.setMessage("密码修改失败!");
				box.open();
				return;
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void btnAddUserWidgetSelected(SelectionEvent evt) {// 增加用户

		String userId = txtUserIdR.getText().trim();
		String userName = txtUserNameR.getText().trim();
		if (userId.equals("")) {
			box.setMessage("用户ID不能为空!");
			box.open();
			return;
		}
		if (userName.equals("")) {
			box.setMessage("用户姓名不能为空!");
			box.open();
			return;
		}

		// 另外增加的
		if (Util.isValidUserId(userId) == false) {
			box.setMessage("用户ID只能由字母、数字、下划线构成，且只能以字母开头，长度不能超过12位!");
			box.open();
			return;
		}

		if (Util.isValidUserName(userName) == false) {
			box.setMessage("用户姓名只能由字母、中文、数字、下划线构成，且只能以字母或中文开头，长度不能超过12位!");
			box.open();
			return;
		}

		String user_type = "";
		if (btnAdmin.getSelection())
			user_type = Util.SYSTEM_ADMIN;
		else if (btnCommonUser.getSelection())
			user_type = Util.COMMON_USER;
		else if (btnReview.getSelection())
			user_type = Util.REVIEW_USER;

		try {
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(txtUserIdR.getText());
			out.add(txtUserNameR.getText());
			out.add(user_type);
			SocketConnection.setCmd("adduser");
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();
			if (in == null || in.size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}
			if (in.get(0).toString().equals("1")) { // 添加成功
				box.setMessage("添加用户成功!");
				box.open();
				txtUserIdR.setText("");
				txtUserNameR.setText("");
				return;
			} else if (in.get(0).toString().equals("-2")) {
				box.setMessage("用户ID已存在!");
				box.open();
				return;
			} else {
				box.setMessage("添加用户失败!");
				box.open();
				return;
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void InitUserProList() { // 用户信息维护，初始化项目列表
		try {
			editUserProjectId.clear();
			editUserProjectName.clear();
			SocketConnection.setCmd("getallproject");
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();
			if (in == null || in.size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}
			if (in.get(0).toString().equals("-1")) {
				String items[] = { "无项目登记" };
				cboProjectQ.setItems(items);
				// 增加
				cboProjectQ.select(0);
			} else {
				int count = in.size() / 2;
				String items[] = new String[count + 1];
				for (int i = 0; i < count; i++) {
					editUserProjectId.add(in.get(2 * i).toString());
					editUserProjectName.add(in.get(2 * i + 1).toString());
					items[i] = in.get(2 * i + 1).toString();
				}
				items[count] = "任意";
				cboProjectQ.setItems(items);
				cboProjectQ.select(count);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void InitProjectProList() { // 项目信息维护，项目信息列表
		try {
			editProjectId.clear();
			editProjectName.clear();
			SocketConnection.setCmd("getallproject");
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();
			if (in == null || in.size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}
			if (in.get(0).toString().equals("-1")) {
				String items[] = { "无项目登记" };
				cboProIdM.setItems(items);
			} else {
				int count = in.size() / 2;
				String items[] = new String[count];
				for (int i = 0; i < count; i++) {
					editProjectId.add(in.get(2 * i).toString());
					editProjectName.add(in.get(2 * i + 1).toString());
					items[i] = in.get(2 * i).toString();
				}
				cboProIdM.setItems(items);
			}
			cboProIdM.select(0);

			InitProjectDetailInfo(cboProIdM.getItem(cboProIdM
					.getSelectionIndex()));
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void InitProjectDetailInfo(String proid) {// 项目信息维护，显示所有项目信息
		try {
			if (cboProIdM.getItem(cboProIdM.getSelectionIndex())
					.equals("无项目登记")) {
				txtProNameM.setText("");
				txtProVersionM.setText("");
				cboSubsysExistedM.removeAll();
				return;
			}
			editProjectUserId.clear();
			editProjectUserName.clear();
			SocketConnection.setCmd("getprojectdetailinfo");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(proid);
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();
			if (in == null || in.size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}
			// 显示项目所有信息
			txtProNameM.setText(in.get(0).toString()); // name
			txtProVersionM.setText(in.get(1).toString()); // version
			int modelNum = Integer.parseInt(in.get(2).toString());
			String[] items = null;
			if (modelNum != 0) {
				items = new String[modelNum];
				for (int i = 0; i < modelNum; i++)
					items[i] = in.get(i + 3).toString();
				cboSubsysExistedM.setItems(items);
				cboSubsysExistedM.select(0);
			} else
				cboSubsysExistedM.removeAll();
			int userNum = Integer.parseInt(in.get(modelNum + 3).toString());
			String[] userItems = null;
			if (userNum != 0) {
				userItems = new String[userNum];
				for (int i = 0; i < userNum; i++) {
					editProjectUserId.add(in.get(modelNum + 4 + 2 * i)
							.toString());
					editProjectUserName.add(in.get(modelNum + 4 + 2 * i + 1)
							.toString());
					// userItems[i] = in.get(modelNum + 4 + 2 * i +
					// 1).toString();
					userItems[i] = in.get(modelNum + 4 + 2 * i + 1).toString()
							+ "(" + in.get(modelNum + 4 + 2 * i).toString()
							+ ")";
				}
				listLeftM.setItems(userItems);
			} else
				listLeftM.removeAll();
			int otherNum = Integer.parseInt(in.get(modelNum + 2 * userNum + 4)
					.toString());
			String[] otherItems = null;
			if (otherNum != 0) {
				otherItems = new String[otherNum];
				for (int i = 0; i < otherNum; i++) {
					editProjectUserId.add(in.get(
							modelNum + 2 * userNum + 5 + 2 * i).toString());
					editProjectUserName.add(in.get(
							modelNum + 2 * userNum + 5 + 2 * i + 1).toString());
					otherItems[i] = in.get(
							modelNum + 2 * userNum + 5 + 2 * i + 1).toString()
							+ "("
							+ in.get(modelNum + 2 * userNum + 5 + 2 * i)
									.toString() + ")";
				}
				listRightM.setItems(otherItems);
			} else
				listRightM.removeAll();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void InitAddProjectUserList() {// 添加项目时，初始化人员列表
		try {
			addProjectUserId.clear();
			addProjectUserName.clear();
			SocketConnection.setCmd("getalluser");
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();
			if (in == null || in.size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}
			if (in.get(0).toString().equals("-1")) {
				String items[] = { "无人员可选" };
				listRight.setItems(items);
			} else {
				String items[] = new String[in.size() / 2];
				for (int i = 0; i < in.size() / 2; i++) {
					addProjectUserId.add(in.get(i * 2).toString());
					addProjectUserName.add(in.get(i * 2 + 1).toString());
					// items[i] = in.get(i * 2 + 1).toString();
					items[i] = in.get(i * 2 + 1).toString() + "("
							+ in.get(i * 2).toString() + ")";
				}
				listRight.setItems(items);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void btnQueryQWidgetSelected(SelectionEvent evt) {// 根据人员的信息查询人员
		String user_type = "1";
		if (btnAdminQ.getSelection())
			user_type = "0";
		else if (btnCommonUserQ.getSelection())
			user_type = "1";
		else if (btnReviewQ.getSelection())
			user_type = "2";
		else if (btnAllTypeQ.getSelection())
			user_type = "-1";

		try {
			SocketConnection.setCmd("queryuser");
			ArrayList<Object> out = new ArrayList<Object>();

			// if (cboProjectQ.getText().equals("任意"))
			if (cboProjectQ.getText().equals("任意")
					|| cboProjectQ.getText().equals("无项目登记"))
				out.add("-1");
			else
				out.add(editUserProjectId.get(findByName(cboProjectQ
						.getItem(cboProjectQ.getSelectionIndex()),
						editUserProjectName)));

			if (txtUserIdQ.getText().equals(""))
				out.add("-1");
			else
				out.add(txtUserIdQ.getText());

			if (txtUserNameQ.getText().equals(""))
				out.add("-1");
			else
				out.add(txtUserNameQ.getText());

			out.add(user_type);

			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();
			if (in == null || in.size() == 0) {
				tblUserQuery.removeAll();
				box.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				box.open();
				System.exit(0);
				//return;
			}
			if (in.get(0).equals("-1")) {
				tblUserQuery.removeAll();
				box.setMessage("没有符合你查询条件的用户！");
				box.open();
				return;
			}
			int userNum = in.size() / 3;
			tblUserQuery.removeAll();

			Color color = new Color(display, new RGB(222, 226, 226));
			String tmp = "";
			for (int i = 0; i < userNum; i++) {
				if (in.get(3 * i + 2).toString().equals("0"))
					tmp = "系统用户";
				else if (in.get(3 * i + 2).toString().equals("1"))
					tmp = "普通用户";
				else if (in.get(3 * i + 2).toString().equals("2"))
					tmp = "审查用户";
				TableItem item = new TableItem(tblUserQuery, SWT.NONE);
				item.setText(new String[] { String.valueOf(i),
						in.get(3 * i).toString(), in.get(3 * i + 1).toString(),
						tmp });
				if (i % 2 == 0)
					item.setBackground(color);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void btnToLeftWidgetSelected(SelectionEvent evt) {// 添加项目----添加人员
		try {
			int index = listRight.getSelectionIndex();
			if (index == -1) {
				box.setMessage("请选择右侧选框中的人员！");
				box.open();
				return;
			}
			if (btnAddPro.getEnabled()) {
				box.setMessage("请先添加项目!");
				box.open();
				return;
			}
			try {
				/*
				 * String userid = addProjectUserId.get(findByName(listRight
				 * .getItem(index), addProjectUserName));
				 */
				String userid = Util.splitUserNameId(listRight.getItem(index))[1];
				SocketConnection.setCmd("addprojectuser");
				ArrayList<Object> out = new ArrayList<Object>();
				out.add(txtProId.getText().toString());
				out.add(userid);
				SocketConnection.setListOut(out);
				SocketConnection.DataTransmission();

				if (SocketConnection.getListIn().get(0).toString().equals("1"))
					System.out.println("add project success!");
				else
					System.out.println("add project failed!");
			} catch (IOException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}

			listLeft.add(listRight.getItem(index));
			listRight.remove(index);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return;
	}

	private void btnToRightWidgetSelected(SelectionEvent evt) {// 添加项目----去除人员
		try {
			int index = listLeft.getSelectionIndex();
			if (index == -1) {
				box.setMessage("请选择左侧选框中的人员！");
				box.open();
				return;
			}
			if (btnAddPro.getEnabled()) {
				box.setMessage("请先添加项目!");
				box.open();
				return;
			}
			try {
				/*
				 * String userid = addProjectUserId.get(findByName(listLeft
				 * .getItem(index), addProjectUserName));
				 */
				String userid = Util.splitUserNameId(listLeft.getItem(index))[1];
				SocketConnection.setCmd("deleteprojectuser");
				ArrayList<Object> out = new ArrayList<Object>();
				out.add(txtProId.getText().toString());
				out.add(userid);
				SocketConnection.setListOut(out);
				SocketConnection.DataTransmission();
				if (SocketConnection.getListIn() == null
						|| SocketConnection.getListIn().size() == 0) {
					failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
					failed.open();
					System.exit(0);
					//return;
				}
				if (SocketConnection.getListIn().get(0).toString().equals("1"))
					System.out.println("delete project success!");
				else
					System.out.println("delete project failed!");
			} catch (IOException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}

			listRight.add(listLeft.getItem(index));
			listLeft.remove(index);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return;
	}

	private void btnResetMemberWidgetSelected(SelectionEvent evt) {// 添加项目----重置
		box1.setMessage("你确定要重置吗?");
		if (box1.open() == SWT.YES) {
			txtProId.setText("");
			txtProName.setText("");
			txtProVersion.setText("");
			txtSubsys.setText("");
		} else
			return;
	}

	private void cboProIdMWidgetSelected(SelectionEvent evt) {// 修改项目信息----项目ID改变时的事件
		InitProjectDetailInfo(cboProIdM.getItem(cboProIdM.getSelectionIndex()));
	}

	private void btnAddSubsysWidgetSelected(SelectionEvent evt) {// 添加项目，添加子系统
		String model = txtSubsys.getText().trim();
		if (model.equals("")) {
			box.setMessage("请填写子系统名称!");
			box.open();
			return;
		}
		if (Util.isValidProjectModel(model) == false) {
			box.setMessage("子系统名称不符合格式要求，只能由字母和数字构成!");
			box.open();
			return;
		}
		if (btnAddPro.getEnabled()) {
			box.setMessage("请先添加项目");
			box.open();
			return;
		}
		try {
			SocketConnection.setCmd("addprojectmodel");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(txtSubsys.getText().toString());
			out.add(txtProId.getText().toString());
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			if (SocketConnection.getListIn() == null
					|| SocketConnection.getListIn().size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}

			String tag = SocketConnection.getListIn().get(0).toString();
			if (tag.equals("1")) {// 添加成功
				box.setMessage("添加子系统成功!");
				box.open();
				cboSubsysExisted.add(txtSubsys.getText().toString());
				cboSubsysExisted.setText(txtSubsys.getText().toString());
				txtSubsys.setText("");
				return;
			} else if (tag.equals("-2")) {
				box.setMessage("此子系统已存在!");
				box.open();
				return;
			} else {
				box.setMessage("添加子系统失败!");
				box.open();
				return;
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void btnAddProWidgetSelected(SelectionEvent evt) {// 添加项目
		String proId = txtProId.getText().trim();
		String proName = txtProName.getText().trim();
		String proVersion = txtProVersion.getText().trim();

		if (proId.equals("")) {
			box.setMessage("请填写项目ID!");
			box.open();
			return;
		}
		if (Util.isValidProjectId(proId) == false) {
			box.setMessage("项目ID格式不符合要求，只能由字母、数字和.构成，且只能以字母开头!");
			box.open();
			return;
		}

		if (proName.equals("")) {
			box.setMessage("请填写项目名称!");
			box.open();
			return;
		}
		if (Util.isValidProjectName(proName) == false) {
			box.setMessage("项目名称格式不符合要求，只能由字母、中文、数字和.构成，且只能以字母或中文开头!");
			box.open();
			return;
		}
		if (proVersion.equals("")) {
			box.setMessage("请填写项目版本号!");
			box.open();
			return;
		}
		if (Util.isValidProjectVersion(proVersion) == false) {
			box.setMessage("项目版本号格式不符合要求，只能由数字和.构成，且只能以数字开头!");
			box.open();
			return;

		}

		try {
			SocketConnection.setCmd("addproject");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(Util.filter(txtProId.getText().toString()));
			out.add(txtProName.getText().toString());
			out.add(txtProVersion.getText().toString());
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			if (SocketConnection.getListIn() == null
					|| SocketConnection.getListIn().size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}
			String tag = SocketConnection.getListIn().get(0).toString();
			if (tag.equals("1")) {// 添加成功
				box.setMessage("添加项目成功!");
				box.open();
				txtProId.setEditable(false);
				txtProName.setEditable(false);
				txtProVersion.setEditable(false);
				btnAddPro.setEnabled(false);
				btnResetMember.setEnabled(false);
				return;
			} else if (tag.equals("-2")) {
				box.setMessage("项目ID已存在!");
				box.open();
				return;
			} else {
				box.setMessage("添加项目失败!");
				box.open();
				return;
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void btnDeleteMemberWidgetSelected(SelectionEvent evt) {// 添加项目，删除选中模块
		if (cboSubsysExisted.getItems().length == 0) {
			box.setMessage("此项目没有子系统！");
			box.open();
			return;
		}
		if (btnAddPro.getEnabled()) {
			box.setMessage("请先添加项目");
			box.open();
			return;
		}
		try {
			SocketConnection.setCmd("deleteprojectmodel");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(txtProId.getText().toString());
			out.add(cboSubsysExisted.getItem(cboSubsysExisted.getSelectionIndex()).toString());
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			if (SocketConnection.getListIn() == null
					|| SocketConnection.getListIn().size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
			//	return;
			}

			String tag = SocketConnection.getListIn().get(0).toString();
			if (tag.equals("1")) {// 添加成功
				box.setMessage("删除子系统成功!");
				box.open();
				cboSubsysExisted.remove(cboSubsysExisted.getText());
				cboSubsysExisted.setText("");
				btnResetMember.setEnabled(false);
				return;
			} else {
				box.setMessage("删除子系统失败!");
				box.open();
				return;
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private int findByName(String name, ArrayList<String> list) {
		int i;
		for (i = 0; i < list.size(); i++)
			if (list.get(i).toString().equals(name))
				break;
		return i;
	}

	private void cboProIdBWidgetSelected(SelectionEvent evt) {// 创建缺陷报告单，项目ID列表
		showModelAndBug(cboProIdB.getItem(cboProIdB.getSelectionIndex()));
	}

	private void btnToLeftMWidgetSelected(SelectionEvent evt) {// 维护项目信息，添加人员
		try {
			int index = listRightM.getSelectionIndex();
			if (index == -1) {
				box.setMessage("请选择右侧选框中的人员！");
				box.open();
				return;
			}
			try {
				/*
				 * String userid = editProjectUserId.get(findByName(listRightM
				 * .getItem(index), editProjectUserName));
				 */
				String userid = Util.splitUserNameId(listRightM.getItem(index))[1];
				SocketConnection.setCmd("addprojectuser");
				ArrayList<Object> out = new ArrayList<Object>();
				out.add(cboProIdM.getItem(cboProIdM.getSelectionIndex()));
				out.add(userid);
				SocketConnection.setListOut(out);
				SocketConnection.DataTransmission();
				if (SocketConnection.getListIn() == null
						|| SocketConnection.getListIn().size() == 0) {
					failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
					failed.open();
					System.exit(0);
					//return;
				}
				if (SocketConnection.getListIn().get(0).toString().equals("1"))
					System.out.println("edit project success!");
				else
					System.out.println("edit project failed!");
			} catch (IOException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
			listLeftM.add(listRightM.getItem(index));
			listRightM.remove(index);
		} catch (Exception ex) {
			ex.printStackTrace();
		}
		return;
	}

	private void btnToRightMWidgetSelected(SelectionEvent evt) {// 维护项目信息，删除人员
		try {
			int index = listLeftM.getSelectionIndex();
			if (index == -1) {
				box.setMessage("请选择左侧选框中的人员！");
				box.open();
				return;
			}
			try {
				/*
				 * String userid = editProjectUserId.get(findByName(listLeftM
				 * .getItem(index), editProjectUserName));
				 */
				String userid = Util.splitUserNameId(listLeftM.getItem(index))[1];
				SocketConnection.setCmd("deleteprojectuser");
				ArrayList<Object> out = new ArrayList<Object>();
				out.add(cboProIdM.getItem(cboProIdM.getSelectionIndex()));
				out.add(userid);
				SocketConnection.setListOut(out);
				SocketConnection.DataTransmission();
				ArrayList<Object> in = SocketConnection.getListIn();

				if (in == null || in.size() == 0) {
					failed.setMessage("服务器连接出错，请检查配置文件和网络连接");
					failed.open();
					return;
				}

				if (in.get(0).toString().equals("1")) {
					listRightM.add(listLeftM.getItem(index));
					listLeftM.remove(index);
				} else {
					failed.setMessage("由于该人员有任务在身，不能移除！");
					failed.open();
				}
			} catch (IOException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}

	private void btnModifyMWidgetSelected(SelectionEvent evt) {// 项目信息维护,修改
		String proName = txtProNameM.getText().trim();
		String proVersion = txtProVersionM.getText().trim();

		if (proName.equals("")) {
			box.setMessage("项目名称不能为空!");
			box.open();
			return;
		}
		if (Util.isValidProjectName(proName) == false) {
			box.setMessage("项目名称格式不符合要求，只能由字母、中文、数字和.构成，且只能以字母或中文开头!");
			box.open();
			return;
		}
		if (proVersion.equals("")) {
			box.setMessage("请填写项目版本号!");
			box.open();
			return;
		}
		if (Util.isValidProjectVersion(proVersion) == false) {
			box.setMessage("项目版本号格式不符合要求，只能由数字和.构成，且只能以数字开头!");
			box.open();
			return;

		}
		try {
			SocketConnection.setCmd("fixproject");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(cboProIdM.getItem(cboProIdM.getSelectionIndex()));
			out.add(txtProNameM.getText());
			out.add(txtProVersionM.getText());
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();

			if (SocketConnection.getListIn() == null
					|| SocketConnection.getListIn().size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}

			if (SocketConnection.getListIn().get(0).toString().equals("1")) {
				box.setMessage("修改成功！");
				box.open();
				return;
			} else {
				box.setMessage("修改失败！");
				box.open();
				return;
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void btnAddSubsysMWidgetSelected(SelectionEvent evt) {// 维护项目信息，添加模块
		try {

			String model = txtSubsysM.getText().trim();
			if (model == null || model.length() == 0) {
				box.setMessage("请输入子系统名称");
				box.open();
				return;
			}
			if (Util.isValidProjectModel(model) == false) {
				box.setMessage("输入的数据格式有误，子系统名称只能由字母和数字组成");
				box.open();
				return;
			}
			SocketConnection.setCmd("addprojectmodel");
			ArrayList<Object> out = new ArrayList<Object>();

			out.add(model);
			out.add(cboProIdM.getItem(cboProIdM.getSelectionIndex()));
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();

			if (SocketConnection.getListIn() == null
					|| SocketConnection.getListIn().size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
			//	return;
			}

			String tag = SocketConnection.getListIn().get(0).toString();
			if (tag.equals("1")) {// 添加成功
				box.setMessage("添加子系统成功!");
				box.open();
				cboSubsysExistedM.add(txtSubsysM.getText().toString());
				cboSubsysExistedM.setText(txtSubsysM.getText().toString());
				txtSubsysM.setText("");
				return;
			} else if (tag.equals("-2")) {
				box.setMessage("此子系统已存在!");
				box.open();
				return;
			} else {
				box.setMessage("添加子系统失败!");
				box.open();
				return;
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void btnDeleteSubsysMWidgetSelected(SelectionEvent evt) {// 维护项目信息，删除模块
		try {
			SocketConnection.setCmd("deleteprojectmodel");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(cboSubsysExistedM.getItem(cboSubsysExistedM
					.getSelectionIndex()));
			out.add(cboProIdM.getItem(cboProIdM.getSelectionIndex()));
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();

			if (SocketConnection.getListIn() == null
					|| SocketConnection.getListIn().size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}

			String tag = SocketConnection.getListIn().get(0).toString();
			if (tag.equals("1")) {// 删除成功
				box.setMessage("删除子系统成功!");
				box.open();
				cboSubsysExistedM.remove(cboSubsysExistedM.getText());
				cboSubsysExistedM.setText("");
				return;
			} else {
				box.setMessage("删除子系统失败!");
				box.open();
				return;
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void InitCreateBug() {// 创建缺陷报告单,初始化页面
		// 初始化项目列表
		try {
			addBugReportProjectId.clear();
			addBugReportProjectName.clear();
			SocketConnection.setCmd("getprojectbyuserid");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(userName);
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();

			if (in == null || in.size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}

			if (in.get(0).toString().equals("-1")) {
				String items[] = { "无项目" };
				cboProIdB.setItems(items);
				cboProIdB.select(0);
			} else {
				int count = in.size() / 2;
				String items[] = new String[count];
				for (int i = 0; i < count; i++) {
					addBugReportProjectId.add(in.get(2 * i).toString());
					addBugReportProjectName.add(in.get(2 * i + 1).toString());
					items[i] = in.get(2 * i).toString();
				}
				cboProIdB.setItems(items);
				cboProIdB.select(0);
			}
			showModelAndBug(cboProIdB.getText());
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		// 时间,人
		try {
			txtSubmit.setText(userName);
			txtTime.setText("xxxx-xx-xx");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void showModelAndBug(String proid) {// 添加报告单，模块
		try {
			addBugReportUserName.clear();
			addBugReportUserId.clear();
			if (cboProIdB.getText().equals("无项目"))
				return;
			SocketConnection.setCmd("getprojectdetailinfo");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(proid);
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			if (SocketConnection.getListIn() == null
					|| SocketConnection.getListIn().size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				//return;
				System.exit(0);
			}

			ArrayList<Object> in = SocketConnection.getListIn();
			// 显示项目所有信息
			// cboProVersionB.setText(in.get(1).toString()); // version
			String[] versions = { in.get(1).toString() };
			cboProVersionB.setItems(versions);
			cboProVersionB.select(0);
			int modelNum = Integer.parseInt(in.get(2).toString());
			String[] items = null;
			if (modelNum != 0) {
				items = new String[modelNum];
				for (int i = 0; i < modelNum; i++)
					items[i] = in.get(i + 3).toString();
				cboSubsysB.setItems(items);
				cboSubsysB.select(0);
			} else
				cboSubsysB.removeAll();
			int userNum = Integer.parseInt(in.get(modelNum + 3).toString());
			String[] userItems = null;
			if (userNum != 0) {
				userItems = new String[userNum];
				for (int i = 0; i < userNum; i++) {
					addBugReportUserId.add(in.get(modelNum + 4 + 2 * i)
							.toString());
					addBugReportUserName.add(in.get(modelNum + 4 + 2 * i + 1)
							.toString());
					// userItems[i] = in.get(modelNum + 4 + 2 * i +
					// 1).toString();
					userItems[i] = in.get(modelNum + 4 + 2 * i + 1).toString()
							+ "(" + in.get(modelNum + 4 + 2 * i).toString()
							+ ")";
				}
				cboReview.removeAll();
				cboReview.setItems(userItems);
				cboReview.select(0);
			} else
				cboReview.removeAll();
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void btnSaveBugWidgetSelected(SelectionEvent evt) {// 创建缺陷报告单 ，保存
		SocketConnection.setCmd("newbugsave");
		newBug();
	}

	private void btnSubmitBugWidgetSelected(SelectionEvent evt) {// 创建缺陷报告单，提交
		SocketConnection.setCmd("newbugsubmit");
		newBug();

		ClearAllAddBugReport();

	}

	private void newBug() {// 创建缺陷报告单
		try {

			ArrayList<Object> out = new ArrayList<Object>();
			out.add(cboProIdB.getItem(cboProIdB.getSelectionIndex()));// proid
			out.add(txtBugId.getText().substring(1));
			out.add(userName);// person
			Date date = new Date();
			Format formatter = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");// 设置格式
			txtTime.setText(formatter.format(date).substring(0, 10));
			out.add(formatter.format(date));// time
			out.add(cboSubsysB.getItem(cboSubsysB.getSelectionIndex()));// model
			// name

			if (txtHard.getText().trim().equals("")) {
				box.setMessage("硬件环境不能为空");
				box.open();
				return;
			} else
				out.add(txtHard.getText());

			if (txtSoft.getText().trim().equals("")) {
				box.setMessage("软件环境不能为空");
				box.open();
				return;
			} else
				out.add(txtSoft.getText());

			out.add(cboSeverity.getSelectionIndex());

			if (txtBugSummary.getText().trim().equals(""))// 概要描述
			{
				box.setMessage("缺陷概要描述不能为空");
				box.open();
				return;
			} else
				out.add(txtBugSummary.getText());

			if (txtBugDetail.getText().trim().equals("")) {
				box.setMessage("缺陷详细描述不能为空");
				box.open();
				return;
			} else
				out.add(txtBugDetail.getText());
			out.add(cboRecur.getSelectionIndex());

			if (cboRecur.getSelectionIndex() == 0
					&& txtRecurStep.getText().trim().equals("")) {
				box.setMessage("重现步骤不能为空");
				box.open();
				return;
			} else
				out.add(txtRecurStep.getText());

			out.add(txtAttach.getText());

			if (btnAssignReview.getSelection()) { // 不关闭
				out.add("next");
				/*
				 * out.add(addBugReportUserId.get(findByName(cboReview
				 * .getItem(cboReview.getSelectionIndex()),
				 * addBugReportUserName)));
				 */
				out.add(Util.splitUserNameId(cboReview.getItem(cboReview
						.getSelectionIndex()))[1]);
			} else {
				out.add("shutdown");
				out.add(cboClose.getSelectionIndex() + 6);
			}
			for (int i = 0; i < out.size(); i++)
				System.out.println(out.get(i));
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();

			if (SocketConnection.getListIn() == null
					|| SocketConnection.getListIn().size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				//return;
				System.exit(0);
			}
			ArrayList<Object> in = SocketConnection.getListIn();
			if (in.get(0).toString().equals("-1")) {
				box.setMessage("添加失败!");
				box.open();
				return;
			} else {
				box.setMessage("操作成功!");
				box.open();
				txtBugId.setText(in.get(0).toString());
				lblBugId.setVisible(true);
				txtBugId.setVisible(true);
				lblSubmit.setVisible(true);
				txtSubmit.setVisible(true);
				lblTime.setVisible(true);
				txtTime.setVisible(true);
			}

		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void ClearAllAddProject() {
		txtProId.setText("");
		txtProName.setText("");
		txtProVersion.setText("");
		txtSubsys.setText("");
		cboSubsysExisted.removeAll();
		listLeft.removeAll();
		listRight.removeAll();
	}

	private void ClearAllAddBugReport() {
		txtBugId.setText("D****");
		txtSubmit.setText(userName);
		txtTime.setText("xxxx-xx-xx");
		txtHard.setText("");
		txtSoft.setText("");
		txtBugSummary.setText("");
		txtAttach.setText("");
		txtBugDetail.setText("");
		txtRecurStep.setText("");
		cboRecur.select(0);
		cboSeverity.select(0);

		btnSaveBug.setEnabled(true);
		btnSubmitBug.setEnabled(true);
		txtRecurStep.setEditable(true);

	}

	private void btnDeleteQWidgetSelected(SelectionEvent evt) {// 删除用户
		if (tblUserQuery.getSelection() != null
				&& tblUserQuery.getSelection().length > 0) {
			try {
				SocketConnection.setCmd("deleteuser");
				ArrayList<Object> out = new ArrayList<Object>();
				out.add(tblUserQuery.getSelection()[0].getText(1));
				SocketConnection.setListOut(out);
				SocketConnection.DataTransmission();

				if (SocketConnection.getListIn() == null
						|| SocketConnection.getListIn().size() == 0) {
					failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
					failed.open();
					//return;
					System.exit(0);
				}
				ArrayList<Object> in = SocketConnection.getListIn();
				if (in.get(0).toString().equals("1")) {
					success.setMessage("删除成功！");
					success.open();
					tblUserQuery.remove(tblUserQuery.getSelectionIndex());
					return;
				} else {
					failed.setMessage("由于该人员有项目在身，删除失败！");
					failed.open();
					return;
				}
			} catch (Exception e) {
				e.printStackTrace();
			}
		} else {
			failed.setMessage("请选择用户");
			failed.open();
		}
	}

	private void btnSaveQWidgetSelected(SelectionEvent evt) {
		try {
			ModifyUser.userID = tblUserQuery.getSelection()[0].getText(1);
			ModifyUser.userName = tblUserQuery.getSelection()[0].getText(2);
			ModifyUser.userType = tblUserQuery.getSelection()[0].getText(3);
			ModifyUser.showGUI();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void InitProjectByUserId() {// 通过userid找到和他相关的项目
		try {
			getProjectByUserIdProjectId.clear();
			getProjectByUserIdProjectName.clear();
			table2.removeAll();
			SocketConnection.setCmd("getprojectbyuserid");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(userName);
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();

			if (in == null || in.size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				//return;
				System.exit(0);
			}

			if (in.get(0).toString().equals("-1")) {
				String[] items = { "无项目" };
				combo7.setItems(items);
				combo7.select(0);
				return;
			}
			String[] items = new String[in.size() / 2];
			for (int i = 0; i < in.size() / 2; i++) {
				getProjectByUserIdProjectId.add(in.get(2 * i).toString());
				getProjectByUserIdProjectName.add(in.get(2 * i + 1).toString());
				items[i] = in.get(2 * i + 1).toString();
			}
			combo7.setItems(items);
			combo7.select(0);
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void InitBugByProject() {
		try {
			table2.removeAll();
			if (combo7.getText().equals("无项目"))
				return;
			SocketConnection.setCmd("getbugbyprojectid");
			ArrayList<Object> out = new ArrayList<Object>();
			out.add(getProjectByUserIdProjectId.get(findByName(
					combo7.getText(), getProjectByUserIdProjectName)));
			out.add(userName);
			SocketConnection.setListOut(out);
			SocketConnection.DataTransmission();
			ArrayList<Object> in = SocketConnection.getListIn();

			if (in == null || in.size() == 0) {
				failed.setMessage("服务器连接出错，请检查配置文件和网络连接！");
				failed.open();
				System.exit(0);
				//return;
			}

			for (int i = 0; i < in.size(); i++)
				System.out.println(in.get(i));
			// Color color = display.getSystemColor(SWT.COLOR_CYAN);
			Color color = new Color(display, new RGB(222, 226, 226));
			if (in.get(0).toString().equals("-1")) {
				TableItem item = new TableItem(table2, SWT.NONE);
				item.setText(new String[] { "", "", "无缺陷报告", "", "", "" });
				item.setBackground(color);
				return;
			}
			int bugNum = in.size() / 6;
			for (int i = 0; i < bugNum; i++) {
				TableItem item = new TableItem(table2, SWT.NONE);
				item.setText(new String[] { String.valueOf(i),
						in.get(i * 6).toString(), in.get(i * 6 + 2).toString(),
						Util.convertToStatusName(in.get(i * 6 + 3).toString()),
						in.get(i * 6 + 4).toString(),
						in.get(i * 6 + 5).toString() });
				if (i % 2 == 0)
					item.setBackground(color);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}

	private void combo7WidgetSelected(SelectionEvent evt) {
		InitBugByProject();
	}

	private void table2WidgetSelected(SelectionEvent evt) {
		if (table2.getSelection() != null && table2.getSelection().length > 0) {
			try {
				EMProcess.ebmsID = table2.getSelection()[0].getText(1);
				if (EMProcess.ebmsID == null
						|| EMProcess.ebmsID.trim().length() == 0)
					return;
				EMProcess.userType = "0";
				EMProcess.userName = SystemAdmin.userName;
				EMProcess.days = table2.getSelection()[0].getText(5);
				EMProcess.responpeo = table2.getSelection()[0].getText(2);
				EMProcess.status = Util
						.convertToStatusId(table2.getSelection()[0].getText(3));
				EMProcess.wtgyms = table2.getSelection()[0].getText(4);
				EMProcess.proID = getProjectByUserIdProjectId.get(findByName(
						combo7.getText(), getProjectByUserIdProjectName));
				EMProcess.isEdit = "true";
				EMProcess.showGUI();
			} catch (Exception ex) {
				ex.printStackTrace();
			}
		}
	}
}